﻿using System;
using HslCommunication.BasicFramework;

namespace HslCommunication.Core.IMessage
{
	/// <summary>
	/// 本组件系统使用的默认的消息规则，说明解析和反解析规则的
	/// </summary>
	// Token: 0x02000158 RID: 344
	public class HslMessage : INetMessage
	{
		/// <inheritdoc cref="P:HslCommunication.Core.IMessage.INetMessage.ProtocolHeadBytesLength" />
		// Token: 0x170005DF RID: 1503
		// (get) Token: 0x06001D42 RID: 7490 RVA: 0x0008D373 File Offset: 0x0008B573
		public int ProtocolHeadBytesLength
		{
			get
			{
				return 32;
			}
		}

		/// <inheritdoc cref="P:HslCommunication.Core.IMessage.INetMessage.HeadBytes" />
		// Token: 0x170005E0 RID: 1504
		// (get) Token: 0x06001D43 RID: 7491 RVA: 0x0008D377 File Offset: 0x0008B577
		// (set) Token: 0x06001D44 RID: 7492 RVA: 0x0008D37F File Offset: 0x0008B57F
		public byte[] HeadBytes { get; set; }

		/// <inheritdoc cref="P:HslCommunication.Core.IMessage.INetMessage.ContentBytes" />
		// Token: 0x170005E1 RID: 1505
		// (get) Token: 0x06001D45 RID: 7493 RVA: 0x0008D388 File Offset: 0x0008B588
		// (set) Token: 0x06001D46 RID: 7494 RVA: 0x0008D390 File Offset: 0x0008B590
		public byte[] ContentBytes { get; set; }

		/// <inheritdoc cref="M:HslCommunication.Core.IMessage.INetMessage.CheckHeadBytesLegal(System.Byte[])" />
		// Token: 0x06001D47 RID: 7495 RVA: 0x0008D39C File Offset: 0x0008B59C
		public bool CheckHeadBytesLegal(byte[] token)
		{
			bool flag = this.HeadBytes == null;
			bool result;
			if (flag)
			{
				result = false;
			}
			else
			{
				byte[] headBytes = this.HeadBytes;
				bool flag2 = headBytes != null && headBytes.Length >= 32;
				result = (flag2 && SoftBasic.IsTwoBytesEquel(this.HeadBytes, 12, token, 0, 16));
			}
			return result;
		}

		/// <inheritdoc cref="M:HslCommunication.Core.IMessage.INetMessage.GetContentLengthByHeadBytes" />
		// Token: 0x06001D48 RID: 7496 RVA: 0x0008D3F0 File Offset: 0x0008B5F0
		public int GetContentLengthByHeadBytes()
		{
			byte[] headBytes = this.HeadBytes;
			bool flag = headBytes != null && headBytes.Length >= 32;
			int result;
			if (flag)
			{
				result = BitConverter.ToInt32(this.HeadBytes, 28);
			}
			else
			{
				result = 0;
			}
			return result;
		}

		/// <inheritdoc cref="M:HslCommunication.Core.IMessage.INetMessage.GetHeadBytesIdentity" />
		// Token: 0x06001D49 RID: 7497 RVA: 0x0008D430 File Offset: 0x0008B630
		public int GetHeadBytesIdentity()
		{
			byte[] headBytes = this.HeadBytes;
			bool flag = headBytes != null && headBytes.Length >= 32;
			int result;
			if (flag)
			{
				result = BitConverter.ToInt32(this.HeadBytes, 4);
			}
			else
			{
				result = 0;
			}
			return result;
		}

		/// <inheritdoc cref="P:HslCommunication.Core.IMessage.INetMessage.SendBytes" />
		// Token: 0x170005E2 RID: 1506
		// (get) Token: 0x06001D4A RID: 7498 RVA: 0x0008D46C File Offset: 0x0008B66C
		// (set) Token: 0x06001D4B RID: 7499 RVA: 0x0008D474 File Offset: 0x0008B674
		public byte[] SendBytes { get; set; }
	}
}
